﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>绑定外键表</title>
    <script type="text/javascript" src="../../../Scripts/bootstrap/js/jquery.min.js"></script>
    <script src="../../../Scripts/QueryString.js" type="text/javascript"></script>
    <link href="../../../Scripts/easyUI145/themes/icon.css" rel="stylesheet" type="text/css" />
    <link href="../../../Scripts/easyUI145/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../../../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    <!-- 引用通用的js文件. -->
    <script type="text/javascript" src="../../../Scripts/config.js"></script>
    <script type="text/javascript" src="../../../Comm/Gener.js"></script>
    <script src="DDLBar.js" type="text/javascript"></script>
    <script type="text/javascript" language="javascript">

        //页面启动函数.
        $(function () {

            InitBar("PopBindSFTable");
            var html = "";
            var mapExt = new Entity("BP.Sys.MapExt");
            mapExt.MyPK = "PopBindSFTable_" + GetQueryString("FK_MapData") + "_" + GetQueryString("KeyOfEn");
            var i = mapExt.RetrieveFromDBSources(); //从数据库来查询.
            if (i == 0) {
                mapExt.H = 300;
                mapExt.W = 600;
                mapExt.SetPara("Title", "请选择");
            }

            if (mapExt.GetPara("SelectType") == "")
                mapExt.SetPara("SelectType", "1");

            //批量为赋值.
            GenerFullAllCtrlsVal(mapExt);

            GenerBindEntities("DDL_SFTable", "BP.Sys.SFTables", mapExt.Tag2);


            //设置按钮是否可以用?
            if (i == 0) {
                $("#Btn_Delete").attr("disabled", true);
                $("#Btn_FullData").attr("disabled", true);
            } else {
                $("#Btn_Delete").removeAttr("disabled");
                $("#Btn_FullData").removeAttr("disabled");
            }
        });
        function Save() {

            //更新节点表单类型.
            var frmID = GetQueryString("FK_MapData");
            var keyOfEn = GetQueryString("KeyOfEn");

            var en = new Entity("BP.Sys.MapAttr", frmID + "_" + keyOfEn);
            en.SetPara("PopModel", "PopBindSFTable");
            en.Update();
            var mapExt = new Entity("BP.Sys.MapExt");
            mapExt.MyPK = "PopBindSFTable_" + GetQueryString("FK_MapData") + "_" + GetQueryString("KeyOfEn");
            mapExt.RetrieveFromDBSources(); //从数据库来查询.

            mapExt.CopyURL();  //从url里面copy数据.
            mapExt.CopyForm(); //从from里面copy数据.

            mapExt.ExtType = "PopBindSFTable";
            mapExt.AttrOfOper = GetQueryString("KeyOfEn");
            mapExt.Tag2 = $("#DDL_SFTable").val();

            // alert(mapExt.Tag2);

            var err = "";
            if (mapExt.GetPara("Title") == "")
                err += '\t\n必填字段[标题]不能为空';

            if (err != "") {
                alert(err);
                return;
            }

            var val = mapExt.Save();
            // alert(val);
            window.location.href = window.location.href;
        }
        function Delete() {

            if (confirm('您确定要删除吗？') == false)
                return;

            var mapExt = new Entity("BP.Sys.MapExt");
            mapExt.MyPK = "PopBindSFTable_" + GetQueryString("FK_MapData") + "_" + GetQueryString("KeyOfEn");
            mapExt.RetrieveFromDBSources(); //从数据库来查询.
            mapExt.Delete();
            window.location.href = window.location.href;
        }

    </script>
    <style type="text/css">
        .style1 {
            height: 21px;
        }
        #bar {
            text-align: left;
        }

        .cs-content-box {
            padding: 0 5px;
        }
    </style>
</head>
<body>
    <div id="bar">
    </div>
    <form id="cc">
    <table id="Table1" style="width: 99%;">
        <tr>
            <th colspan="4">
                基本信息
            </th>
        </tr>
        <tr>
            <td>
                标题
            </td>
            <td colspan="3">
                <input type="text" id="TBPara_Title" name="TBPara_Title" style="width: 99%;" />
                <br />
                <font color="gray">显示在窗口的文字，比如:请选择采购产品. </font>
            </td>
        </tr>
        <tr>
            <td>
                弹窗属性
            </td>
            <td>
                高度:<input type="text" id="TB_H" name="TB_H"  style="width: 80px; text-align: right" />
                宽度:<input type="text" id="TB_W" name="TB_W" style="width: 80px; text-align: right" />
                <font color="gray">用于控制弹出窗口的大小</font>
            </td>
            <td>
                设置显示列数
            </td>
            <td>
                <input id="TBPara_ShowCol" name="TBPara_ShowCol" value="2" style="width: 40px; text-align: right" />列
            </td>
        </tr>
        <tr>
            <td>
                数据源类型
            </td>
            <td>
                无
            </td>
            <td>
                选择类型
            </td>
            <td>
                <input type="radio" id="RBPara_SelectType_0" name="RBPara_SelectType" value="0" checked="true" />
                <label for="RBPara_SelectType_0">
                    单选</label>
                <input type="radio" id="RBPara_SelectType_1" name="RBPara_SelectType" value="1" />
                <label for="RBPara_SelectType_1">
                    多选</label>
            </td>
        </tr>
        <tr>
            <td colspan="1">
                <a href="javascript:ShowHidden('entity')">选择一个外键、外部数据源</a>
                <div id="entity" style="color: Gray; display: none">
                    <ul>
                        <li>设置一个可以返回json的数据源该数据源有No,Name, 关联外键列 三个约定的列. </li>
                        <li>比如:Url事例: /DataUser/Handler.ashx?DoType=Demo_Students</li>
                        <li>SQL事例: SELECT No,Name,FK_BanJi FROM Demo_Student</li>
                    </ul>
                </div>
            </td>
            <td colspan="3">
                <select id="DDL_SFTable" name="DDL_SFTable">
                </select>
            </td>
        </tr>
        <tr>
            <th colspan="4">
                <a href="javascript:ShowHidden('backFunction')">确定后执行的JS</a>
                <div id="backFunction" style="color: Gray; display: none">
                    <ul>
                        <li>该选项可以为空,弹出框确定后执行的JS，可以直接写方法名或者方法().</li>
                    </ul>
                </div>
            </th>
        </tr>
        <tr>
            <td colspan="4">
                <input type="text" id="TB_Tag5" name="TB_Tag5" style="width: 99%;" />
            </td>
        </tr>
    </table>
    </form>
</body>
</html>
